<?php
/*
 module:		发布管理
 create_time:	2022-03-09 16:30:59
 author:	陕西格创
 contact:		
*/

namespace app\api\controller;
use app\api\service\ZhMatchmakerCashService;
use app\api\model\ZhMatchmakerCash as ZhMatchmakerCashModel;
use think\facade\Db;
use app\api\model\ZhChat ;
use app\api\model\Member as MemberModel;
class ZhMatchmakerCash extends Common
{


    function index()
    {
        $m_id = intval($this->request->get('m_id'));
        $limit = $this->request->get('limit', 20, 'intval');
        $page = $this->request->get('page', 1, 'intval');
        $where = [];

        if ($m_id > 0) {
            $where['c.m_id'] = $m_id;
        }
        $res = ZhMatchmakerCashService::indexList(formatWhere($where), $limit, $page);
        foreach ($res['list'] as &$v) {
            $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
             $v['updatetime'] = date('Y-m-d H:i:s', $v['updatetime']);
        }
        return $this->ajaxReturn($this->successCode, '返回成功 前端传递的m_id: '.$m_id, $res);
    }

    function view()
    {
        $id=$this->request->get('id');
        if($id<=0){
            return $this->ajaxReturn($this->errorCode, '请传正确id');
        }
        $sql = 'select  o.status,o.updatetime,o.createtime, o.price,gc_zh_matchmaker.name  m_name,gc_zh_matchmaker.phone ,c.price cash_price,c.id,ch.entry_name,ch.comment
                from zh_matchmaker_cash   as c  
                left join gc_zh_matchmaker  on c.m_id=gc_zh_matchmaker.matchmaker_id
                left join    gc_zh_matchmaker_order o on o.id = c.o_id
                left join  gc_zh_matchmaker_charge as ch on ch.id=c.c_id
                where c.id = '.$id.' limit 1';
        $info = Db::connect('mysql')->query($sql)[0];
         $info["createtime"]=date("Y-m-d H:i:s",$info["createtime"]);
        $info["updatetime"]=date("Y-m-d H:i:s",$info["updatetime"]);
        return $this->ajaxReturn($this->successCode, '返回成功', $info ?: '');
    }


}

